/**
 * Created by JetBrains WebStorm.
 * User: matao01
 * Date: 11-9-12
 * Time: 下午7:22
 * To change this template use File | Settings | File Templates.
 */

(function(){
    var Panel = window.Panel || {};
    Panel.Statebar = function(panel){
        this.panel = panel;
        this.dom = this.createHtml();
    }

    Panel.Statebar.prototype = {
        createHtml: function(){
            var state = document.createElement('div');
            state.id = 'panel-statebar-' + this.panel.uid;
            state.className = 'panel-statebar';
            return state;
        },

        /**
         * show specifing info on statebar
         */
        showInfo: function(info){
            var statebarDom = this.dom;
            if(statebarDom.style.visibility=='hidden'){
                statebarDom.style.visibility = 'visible';
            };
            this.setValue(info);
        },

        /**
         * filter html tag and set innerHTML
         * @param str
         */
        setValue: function(str){
            this.dom.innerHTML = str.replace(/<[^>]*>/g, '');
        },

        /**
         * hide statebar
         */
        hide: function(){
            var statebarDom = this.dom;
            if(statebarDom.style.visibility!='hidden'){
                statebarDom.style.visibility = 'hidden';
            };
        },

        /**
         * clear contents of statebar
         */
        clear: function(){
            this.dom.innerHTML = '';
        }
    };
})();
